#!/usr/bin/python3
# -*- coding: utf-8 -*-

import yaml
import os
BASE_DIR = os.path.abspath(os.path.dirname(__file__))
config_path = os.path.join(BASE_DIR, 'config/web.yaml')

config = {}


def load_config(path):
    if not os.path.exists(path):
        return
    with open(path) as f:
        conf = yaml.safe_load(f)
        set_config(conf)
    return config


def set_config(conf):
    global config
    config = dict(config, **conf)
    return config

def config_init():
    global config
    config = {}
    load_config(config_path)
    load_config('config/web.yaml')
    return config
